<script setup lang="ts">
import { ref, onMounted } from 'vue';
import Top from './modules/Top.vue';
import Tourist from './modules/Tourist.vue';
import Gender from './modules/Gender.vue';
import Age from './modules/Age.vue';
import Map from './modules/Map.vue';
import Line from './modules/Line.vue';
import Rank from './modules/Rank.vue';
import Year from './modules/Year.vue';
import Counter from './modules/Couter.vue'

// 数据大屏内容dom
const screen = ref<HTMLDivElement>()

// 生成当前大屏缩放比例
const getScale = (w: number = 1920, h: number = 1080) => {

    // 宽度比例
    const ww = window.innerWidth / w;
    // 高度比例
    const hh = window.innerHeight/ h;

    return ww < hh ? ww : hh;
}

onMounted(() => {
    // 初始化缩放
    if(screen.value) {
        screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
    }
    // console.log(window.innerWidth);
})

</script>
<template>
    <div class="container">
        <!-- 数据大屏展示内容区域 -->
        <div class="screen" ref="screen">
            <div class="top">
                <Top></Top>
            </div>
            <div class="bottom">
                <div class="left" >
                    <Tourist class="tourist"></Tourist>
                    <Gender class="gender"></Gender>
                    <Age class="age"></Age>
                </div>
                <div class="center">
                    <Map class="map"></Map>
                    <Line class="line"></Line>
                </div>
                <div class="right">
                    <Rank class="rank"></Rank>
                    <Year class="year"></Year>
                    <Counter class="counter"></Counter>
                </div>
            </div>
        </div>
        <!-- 数据大屏展示内容区域 -->
    </div>
</template>



<style scoped lang="scss">
.container {
    width: 100vw;
    height: 100vh;
    background-image: url(./images/bg.png);
    background-repeat: no-repeat;
    background-size : cover;
    .screen {
        position: fixed;
        left: 50%;
        top: 50%;
        width: 1920px;
        height: 1080px;
        transform-origin: left top;
        .top {
            width: 100%;
            height: 40px;
        }
        .bottom {
            padding-top: 10px;
            display: flex;
            .right {
                flex: 1;
                // background: red;
                height: 1040px;
                display: flex;
                flex-direction: column;
                .rank {
                    flex: 1.2;
                   
                }
                .year {
                    flex: 1;
                    
                }
                .counter {
                    flex: 1;
                    
                }
            }
            .left {
                flex: 1;
                // background: red;
                height: 1040px;
                display: flex;
                flex-direction: column;
                justify-content: space-evenly;
                .tourist {
                    flex: 1;
                    // background: #000;
                }
                .gender {
                    flex: 1;
                    
                }
                .age {
                    flex: 1;
                   
                }
            }
            .center {
                flex: 2;
                // background: red;
                display: flex;
                flex-direction: column;
                justify-content: space-evenly;
                
                .map {
                    flex: 3;
                    // background: #000;

                }
                .line {
                    flex: 1;
                    margin: 0 5px;
                }
            }
        }
    }
}
</style>